import request from "@/utils/request";

//注册账号
export function register(data){
return request({
    url:`/user/register/`,
    method:'post',
    data
})
}
//获取验证码
export function getCaptcha(email){
    return request({
        url:`/user/getCaptcha/${email}`,
        method:'get'
    })
}
//重置密码
export function resetPassword(email,newPassword){
  return request({
    url:`/user/resetPassword/${email}/${newPassword}`,
    method:'put'
  })
}
//登录
export function login(accountName,password){
  return request({
    url:`/user/login`,
    method:'get',
    params:{accountName,password}
  })
}

//获取用户信息
export function getUserInfo(){
  return request({
    url:`/user/getInfo`,
    method:'get'
  })
}

//修改用户信息
export function updateUserInfo(info,data){
    return request({
        url:`/user/updateUserInfo/${info}`,
        method:'put',
        data
    })
}

/**
 * 判断用户是否存在
 * @param name
 * @param email
 * @returns {*}
 */
export function isExitUser(name,email){
    return request({
        url:`/user/isExistUser/${name}/${email}`,
        method:'get'
    })
}

/**
 * 个人中心获取用户信息
 * @param username
 * @returns {*}
 */
export function getInfo(username){
    return request({
        url:`/user/getUserInfo/${username}`,
        method:'get'
    })
}
/**
 * 冻结账户
 * @param userId
 * @returns {*}
 */
export function freezeAccount(userId){
    return request({
        url:`/user/freezeAccount/${userId}`,
        method:'put'
    })
}

/**
 * 解冻账户
 * @param userId
 * @returns {*}
 */
export function unFreezeAccount(userId){
    return request({
        url:`/user/unFreezeAccount/${userId}`,
        method:'put'
    })
}

/**
 * 修改用户权限
 * @param userId
 * @param role
 * @returns {*}
 */
export function updateRole(userId,role){
    return request({
        url:`/user/updateRole/${userId}/${role}`,
        method:'put'
    })
}

/**
 * 分页获取用户列表
 * @param page
 * @param limit
 * @returns {*}
 */
export function getUserList(page,limit){
    return request({
        url:`/user/getUserList/${page}/${limit}`,
        method:'get'
    })
}

/**
 * 根根据用户id或名称或email获取用户信息
 * @param eNOE
 * @returns {*}
 */
export function searchUser(eNOE){
    return request({
        url:`/user/searchUserInfo`,
        method:'get',
        params:{eNOE}
    })
}

/**
 * 发布实时公告
 */
export function publishRealA(data){
    return request({
        url:`/realTimeAnnounce/publishReal`,
        method:'post',
        data
    })
}
/**
 * 获取实时公告
 */
export function getRealA(page,limit){
    return request({
        url:`/realTimeAnnounce/getReal/${page}/${limit}`,
        method:'get'
    })
}
/**
 * 获取实时公告
 */
export function deleteReal(ids){
    return request({
        url:`/realTimeAnnounce/deleteReal`,
        method:'delete',
        data:ids
    })
}
